<?php
/********************************************************************************
 * File: sets.php
 * Desc: Displays all of your flickr sets and shows all photos in the set.
 * Args: setId - int optional.   
 *          Id of the set whos photos should be shown.  If none, show all sets.
 *
 * Change   Date        By          Description
 * 1        05/13/2007  mcarruth    Created
 ********************************************************************************/
 
require_once("inc/header.inc");
echo "<script type='text/javascript' src='js/mootools.js'></script>\n";
echo "<script type='text/javascript' src='js/slimbox.js'></script>\n";
echo "<link rel='stylesheet' href='css/slimbox.css' type='text/css' media='screen' />\n";

if (!$_GET['setId']) {
   $sets = $f->photosets_getList($config_flickrUserId);

   echo "<div id='page_header'>\n";
   echo    "<span id='page_title'>Archives</span>\n";
   echo    "<span id='page_nav'>\n";
   echo    "</span>\n";
   echo "</div>\n";
   echo "<div id='page'>\n";
   
   foreach ($sets['photoset'] as $set) {
      $photo = $f->photos_getInfo($set['primary']);
      echo "<div class='photoset_thumbnail'>\n";
      echo    "<a href='sets.php?setId=" . $set['id'] . "' title='" . $set['description'] . "'>\n";
      echo       "<img src='" . $f->buildPhotoURL($photo, "Square") . "' title='" . $set['description'] . "'/>\n";
      echo       "<br/>" . $set['title'];
      echo    "</a>\n";
      echo "</div>\n";
   }
   
   echo    "<div style='clear:both'></div>\n";
   echo "</div>\n";
} 
else {
   $setId = $_GET['setId'];
   $page = $_GET['page'] ? $_GET['page'] : 1;
   $prev = $page - 1;
   $next = $page + 1;
   $photos = $f->photosets_getPhotos($setId, "date_taken", NULL, 54, $page);
   $info = $f->photosets_getInfo($setId);

   echo "<div id='page_header'>\n";
   echo    "<span id='page_title'>" . $info['title'] . "</span>\n";
   echo    "<span id='page_nav'>\n";
   if (0 < $prev) {
      echo    "<a href='sets.php?setId=$setId&page=$prev'>prev</a> ";
   }
   if ($next <= $photos['pages']) {
      echo    "<a href='sets.php?setId=$setId&page=$next'>next</a> ";
   }
   echo    "</span>\n";
   echo "</div>\n";
   echo "<div id='page'>\n";
  
   foreach ($photos['photo'] as $photo) {
      $photoInfo = $f->photos_getInfo($photo['id']);
      $datePosted = date("F j, Y", $photoInfo['dates']['posted']);
      echo "<a href='" . $f->buildPhotoURL($photo, "Medium") . "' rel='lightbox[recent]' title='" . $photo['title'] . " | " . $datePosted . "' name='" . $photo['id'] . "'>\n";
      echo "   <img class='thumbnail' src='" . $f->buildPhotoURL($photo, "Square") . "' title='" . $photo['title'] . " | " . $datePosted . "' alt='" . $photo['title']  . "' />\n";
      echo "</a>\n";   
   }
   
   echo "</div>\n";
}

require_once("inc/footer.inc"); 

?>
